<?
require '../modelo/m.usuario.php';
extract($_REQUEST);
$mUsuario=new usuario();
$total=$mUsuario->validar_usuario($usuario,$password);
if($total<=0){
	$mUsuario->salida("usuario o clave incorrecta","../index.php");
}else
{
if(is_array($total))
			{
                                $mUsuario->inicar($total[0]["idusuario"]);                            
                                
				if($total[0]["idrol"]==1){
                                    session_start();
                                    $_SESSION["cLogin"]["login"] = $total[0]["login"];
                                    $_SESSION["cLogin"]["idrol"] = $total[0]["idrol"];
                                    $_SESSION["cLogin"]["idusuario"] = $total[0]["idusuario"];
                                    header("location: ../admin.php");
				}
				if($total[0]["idrol"]==2){
                                    session_start();
                                    $_SESSION["cLogin"]["login"] = $total[0]["login"];
                                    $_SESSION["cLogin"]["idrol"] = $total[0]["idrol"];
                                    $_SESSION["cLogin"]["idusuario"] = $total[0]["idusuario"];
                                    header("location: soporte.php");
				}
				if($total[0]["idrol"]==4){
                                    session_start();
                                    $_SESSION["cLogin"]["login"] = $total[0]["login"];
                                    $_SESSION["cLogin"]["idrol"] = $total[0]["idrol"];
                                    $_SESSION["cLogin"]["idusuario"] = $total[0]["idusuario"];
                                    header("location: ../usuario.php");
				}
				
			}
			else header("location: index.php?action=error");
}
?>
